package DataLayer;
/**
 * @author: Lam Thanh Trung 1101706
 * @purpose: Lop dung de kiem tra trang thai dang nhap cua user
 * @Date: 18/9/2013
 */
import BusinessLogic.Encrypt;
import java.sql.SQLException;
import java.sql.ResultSet;

public class ChatLogin {
    
    private ChatQuery query;
    private ResultSet rs;
    
    public ChatLogin() throws SQLException, ClassNotFoundException{
        super();
        this.rs=null;
        this.query=new ChatQuery();
    }
    
    public boolean Login(String username, String password){
        try{
            String strSQL = "select Username, Password from User where Username = '" + username + "' and Password = '" + Encrypt.pass(password)+ "'";
            this.rs = this.query.getRs(strSQL);
            if (this.rs != null && this.rs.next()) {
                this.query.closeCon();
                return true;
            } 
            else {
                return false;
            }
        }
        catch(Exception e){
            return false;
        }
    }
}
